package com.heima.homework.day605_开班;

import java.util.Random;

public class Test1 {
    //随机生成六个1-10（包含10）之间的数存入数组中,然后计算出去掉最大值与最小值的平均数，输出格式如下
    public static void main(String[] args) {
        Random r = new Random();

        int[] arr = new int[6];
        int max = arr[0];
        int min = arr[0];
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            arr[i] = r.nextInt(10) + 1;
            System.out.print( arr[i]+"  ");
            sum += arr[i];
            if (max < arr[i]) {
                max = arr[i];
            } else if (min>arr[i]) {
                min=arr[i];
            }
        }


        int avg=(sum-max-min)/4;
        System.out.println("平均数为： "+avg);

    }
}
